package com.lcm.basic.p6.gc;

/**
 * @author Coder-lcm
 * @date 2021/4/3
 */
public class FinalizeDemo2 {
    private static FinalizeDemo2 INSTANCE = null;

    public static void main(String[] args) {
        INSTANCE = new FinalizeDemo2();
        System.out.println("instance now:" + INSTANCE);
        /**
         * 下面代码执行之后，此时原对象将失去引用而去活，即将被GC回收
         */
        INSTANCE = new FinalizeDemo2();
        System.out.println("instance now:" + INSTANCE);
        System.gc();
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("对象即将回收：" + this);
    }
}
